package hk.mrtomato.control;

import hk.mrtomato.dto.MrdateDTO;
import hk.mrtomato.help.ActionForward;
import hk.mrtomato.model.MrBoardService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class WriteDateAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) {
		
		ActionForward forward = new ActionForward();
		MrBoardService manager = MrBoardService.getInstance();
		String id = request.getParameter("id");
		String title = request.getParameter("title");
		String content = request.getParameter("content");
		String mrdate = request.getParameter("mrdate");
		MrdateDTO dto = new MrdateDTO();
		dto.setId(id);
		dto.setTitle(title);
		dto.setContent(content);
		dto.setMrdate(mrdate);
		boolean isC = manager.insertDate(dto);
		if(isC) {
			forward.setUrl("afterwrite");
		}
		return forward;
	}

}
